package com.bestcem.xm.ticket.enums;

import lombok.Getter;

/**
 * 组织状态枚举
 *
 * @author ympan <yuming.pan@idiaoyan.com>
 * @version v1.0
 * @date 2021/8/27 11:32
 */
@Getter
public enum OrganizationStatusEnum {

    /**
     * 启用中
     */
    ORGANIZATION_STATUS_ACTIVATED("ORGANIZATION_STATUS_ACTIVATED", 0),

    /**
     * 停用中
     */
    ORGANIZATION_STATUS_INACTIVATED("ORGANIZATION_STATUS_INACTIVATED", 1),

    /**
     * 已过期
     */
    ORGANIZATION_STATUS_EXPIRED("ORGANIZATION_STATUS_EXPIRED", 2);

    private final String name;

    private final Integer index;

    OrganizationStatusEnum(String name, Integer index) {
        this.name = name;
        this.index = index;
    }

    /**
     * 根据 index 获取枚举实体
     * 找不到则返回 null
     *
     * @param index 组织状态index
     * @return 组织状态枚举
     * @author <yuming.pan@idiaoyan.com>
     * @date 11:34 2021/8/27
     */
    public static OrganizationStatusEnum getByIndex(Integer index) {
        for (OrganizationStatusEnum value : values()) {
            if (value.getIndex().equals(index)) {
                return value;
            }
        }
        return null;
    }
}
